<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/jsp/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>
<script type="text/javascript"
    src='<s:url value="/common/js/common.js"></s:url>'></script>
<script type="text/javascript">
    window.onload = function() {
        var identify_code = document.getElementById("identify_code");
        identify_code.onclick = function() {
            identify_code.src = "<s:url value='/commonActionImpl!getImage'></s:url>";
        };
        var loginForm_mySubmit = document.getElementById("loginForm_mySubmit");
        loginForm_mySubmit.onclick = function() {
            var username = document.getElementById("loginForm_username");
            var password = document.getElementById("loginForm_password");
            var identify = document.getElementById("loginForm_identify");
            if (username.value.Trim() == "") {
                alert("请输入用户名！");
                return false;
            }
            if (password.value.Trim() == "") {
                alert("请输入密码！");
                return false;
            }
            if (identify.value.Trim() == "") {
                alert("请输入验证码！");
                return false;
            } else if (identify.value.length != 4) {
                alert("验证码长度错误！");
                return false;
            }
            var loginForm = document.getElementById("loginForm");
            loginForm.submit();
        };
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest();
        } else {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    };
</script>
</head>
<body>
    <s:form action="userActionImpl!login" id="loginForm" method="post">
        <s:textfield label="用户名" name="username"></s:textfield>
        <s:password label="密码" name="password"></s:password>
        <s:textfield label="验证码" name="identify"></s:textfield>
        <tr>
            <td class="tdLabel"></td>
            <td><img id="identify_code"
                src='<s:url value="/commonActionImpl!getImage"></s:url>' /></td>
        </tr>
        <s:submit name="mySubmit" value="登陆"></s:submit>
    </s:form>

    <a href='<s:url value="userActionImpl!toRegister"></s:url>'>注册</a>
</body>
</html>